<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        ul{
            display: flex;
            list-style: none;
        }
        ul li img{
            width: 300px;
            height: 200px;
        }
        .box{
            position: fixed;
            width: 500px;
            height: 400px;
        }
        .box img{
            width: 500px;
            height: 400px;
        }
    </style>
</head>
<body>
    <ul>
        <li><img class="img" src="1.jpg" alt=""></li>
        <li><img class="img" src="2.jpg" alt=""></li>
        <li><img class="img" src="3.jpg" alt=""></li>
    </ul>
    <div class="box"></div>
    <script>
        let img=document.querySelectorAll(".img");
        let box=document.querySelector(".box");
        for(i=0 ;i<img.length;i++){
            console.log(i);
            img[i].onmouseenter=function(){
                let url=this.src;
                box.innerHTML=`<img src="${url}" alt="">`;
            }
            img[i].onmousemove=function(e){
                let x=e.clientX;
                let y=e.clientY;
                box.style.top=y+20+"px";
                box.style.left=x+20+"px";
            }
            img[i].onmouseleave=function(){
                box.innerHTML="";
            }
        }
    </script>
</body>
</html>